package tcp;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import domain.ServerDomainController;

public class TCPController {
	
	private ServerDomainController dc;

	public TCPController(ServerDomainController dc){
		this.dc = dc;
		
	}
	
	public File acceptFile(){
		try {
			ServerSocket ss = new ServerSocket(12345);
			File myFile = File.createTempFile("myCurrentSong",".abd",new File("C:\\"));
				Socket sock = ss.accept();
				System.out.println("accepted socket");
				byte[] byteArray = new byte[8192];
				BufferedInputStream bis = new BufferedInputStream(new FileInputStream(myFile));
				bis.read(byteArray, 0, byteArray.length);
				return myFile;
		} catch (IOException e) {
			System.out.println("tcp accept: "+e);
		}
		return null;
	}
	
	

}
